package com.chinasofti.io;

import java.io.FileOutputStream;
import java.io.IOException;

public class Demo03 {
    public static void main(String[] args){

        FileOutputStream fos = null;
        //写数据
        try {
            fos = new FileOutputStream("java419\\fos.txt",true);
            for (int i = 0; i < 10; i++) {
                fos.write("hello".getBytes());
                fos.write("\r\n".getBytes());
            }
        }catch (IOException e){
            e.printStackTrace();
        }finally { //finally总的代码一定会执行
            //关闭资源
            try {
                fos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}